<template>
  <div id="app">
    <!-- <router-view v-if="isReload" /> -->

    <!-- 需要缓存的视图组件 -->
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive && isReload" />
    </keep-alive>
    <!-- 不需要缓存的视图组件 -->
    <router-view v-if="!$route.meta.keepAlive && isReload" />

    <div class="test" v-if="isTest">测试环境</div>
  </div>
</template>

<script>
  import WebIM from "./utils/WebIM.js";
  import { mapState, mapActions } from "vuex";
  import { BASEURL } from "../public/static/config";
  export default {
    name: "App",
    provide() {
      return {
        reload: this.reload
      }
    },
    data() {
      return {
        isReload: true,
        isTest: BASEURL.indexOf("utea88.com") < 0 ? true : false
      };
    },
    created() {
      // console.log(123123123, BASEURL.indexOf("utea88.com"))
    },
    beforeMount(){
    		const userInfo = localStorage.getItem("userInfo") && JSON.parse(localStorage.getItem("userInfo"));
        console.log('登录');
    		if(userInfo){
    			const userName = userInfo.userId;
    			const password = userInfo.password;
    			var options = {
    				user: userName,
    				pwd: password,
    				appKey: WebIM.config.appkey
    			};
    			WebIM.conn.open(options);
    		}
    	},
    methods: {
      reload() {
        this.isReload = false
        this.$nextTick(() => {
          this.isReload = true
        })
      }
    },
  };
</script>
<style lang="scss">
  /* body,
html {
  min-width: 1200px;
} */
  a {
    text-decoration: none;
    color: inherit;
  }

  li {
    list-style: none;
  }

  h1,
  h2,
  h3,
  h4,
  h5 {
    margin: 0;
    padding: 0;
    font-weight: 400;
  }

  ul {
    margin: 0;
    padding: 0;
  }

  p {
    margin: 0;
    padding: 0;
  }

  .front {
    min-width: 1200px;
  }

  .hover:hover {
    color: #965f29;
  }

  /* 查看图标颜色 */
  .el-image-viewer__close {
    color: #FFFFFF;
  }

  .test {
    position: fixed;
    top: 0;
    right: 200px;
    background: red;
    color: white;
    margin: 5px;
    padding: 5px;
    font-size: 25px;
    opacity: 0.5;
    z-index: 999999;
  }

  .el-table {
    padding: 0;
    font-size: 11.5px;
    border-color: gray;
    border-bottom-color: gray !important;
    border-bottom: 1px solid gray !important;
    th {
      border-color: gray;
      border-bottom-color: gray !important;
    }

    td {
      border-color: gray;
    } 
  }

  .el-table__body tr,
  .el-table__body td {
    padding: 0;
    margin: 0;
    height: 15px !important;
}
</style>
